Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Pre-Publish Panel from Displaying Incorrect Information After Navigating away #67010

Merged
merged 5 commits into from
Nov 19, 2024

Conversation

sarthaknagoshe2002
Copy link
Contributor

@sarthaknagoshe2002 sarthaknagoshe2002 commented Nov 14, 2024

Fixes: #64913

What?

This PR addresses a bug highlighted in #64913 where the pre-publish panel displays incorrect or broken information when switching to edit a template part. Specifically, if you open the pre-publish checks and immediately switch to edit a template part, the panel continues to show details about the template part, instead of closing or updating appropriately.

Why?

This fix improves the user experience by preventing confusion caused by incorrect information in the pre-publish panel. It ensures the behavior aligns with expectations, where the pre-publish is closed when navigating away.

How?

The issue is resolved by ensuring that when the user navigates away from editing the page, the pre-publish panel is closed. This change ensures that the publish flow is not interrupted and the pre-publish checks are only shown for the current page or post, not the template part.

Testing Instructions

  1. Open a draft page in the editor
  2. Ensure pre-publish checks are enabled
  3. Click on publish to open the pre-publish panel
  4. Select the header then click 'Edit' in the block toolbar
  5. Now the pre-publish panel closes when navigating away

Screenshots or screencast

pre-publish.panel.bug.mov

Copy link

github-actions bot commented Nov 14, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: sarthaknagoshe2002 <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: jameskoster <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 14, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @sarthaknagoshe2002! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

( prevProps.isPublished &&
! this.props.isSaving &&
this.props.isDirty ) ||
! this.props.postlink
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better check would be to see if the currentPostId changed: this.props.currentPostId !== prevProps.currentPostId, where currentPostId is select(editorStore).getCurrentPostId().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ntsekouras, thanks for suggesting a better approach!
I have implemented the suggested changes, please have a look.

Thanks 🙌🏻

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Let's use getCurrentPostId selector though instead of getEditedPostAttribute( 'id' ) and name the prop currentPostId for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntsekouras I have implemented the changes!
Also, can you highlight on why using getCurrentPostId is a better approach?

Thanks 🙌🏻

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Since we only want the id, getCurrentPostId returns that directly from the state whereas getEditedPostAttribute is a doing more and we don't need to fetch all the edits etc..

@ntsekouras ntsekouras added [Type] Bug An existing feature does not function as intended [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Nov 18, 2024
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you! Mobile tests have an issue in general now, so let's see if they are resolved soon and try to rebase and land.

@ntsekouras ntsekouras merged commit 5d24deb into WordPress:trunk Nov 19, 2024
64 of 65 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 19, 2024
@sarthaknagoshe2002 sarthaknagoshe2002 deleted the fix/issue-64913 branch November 19, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pre-publish checks showing template part details
2 participants